package com.example.qinghe.service.communication;


import com.example.qinghe.dao.communication.StaffMapper;
import com.example.qinghe.entity.Common;
import com.example.qinghe.entity.communication.Enterprise;
import com.example.qinghe.entity.communication.Staff;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * AdminService业务层处理
 * 
 * @author ruoyi
 * @date 2023-07-29
 */
@Service
public class StaffService
{
    @Autowired
    private EnterpriseService enterpriseService;
    @Autowired
    public StaffMapper dao;
    //查看员工的具体信息
    public Common sel(Long id)
    {
        return dao.sel(id);
    }

    //根据名字查看员工
    public List<Common>  selbyname(String ward)
    {
        return dao.selbyname(ward);
    }

    //查看同部门的员工信息
    public List<Common> list(Common common){return  dao.list(common);}

    //查看下属的员工id
    public List<Common> list2(Common common){return  dao.list2(common);}

    //登录

    public Staff login(Common common){return dao.login(common);}


    public String getBelong(Long eid) {
        System.out.println("eid:"+eid);
        Enterprise detail = enterpriseService.detail(eid);
        String belong=detail.getName();
        while (detail.getParent_id()!=1)
        {
            detail = enterpriseService.detail(detail.getParent_id());
            belong= detail.getName()+" "+belong;
        }
        return belong;
    }

    public List<Staff> selAll() {

        return dao.selAll();
    }

    public int addStaff(Staff staff) {
        return dao.addStaff(staff);
    }
}
